
module Demo01 where

import Lambola.FI
import Lambola.Stub
import Lambola.IDL.ParsecLexer
import Lambola.IDL.ParsecParser
import qualified Lambola.IDL.Pretty as PP
import Lambola.IDL.Syntax 

import qualified Lambola.IDL.Parser as HAPPY

import Text.Parsec.String
import Text.PrettyPrint.HughesPJ ( render )           -- package: pretty

import Data.Char
import Data.Int
import Data.Word

temp001 = maxBound :: Int32
temp002 = maxBound :: Int16
temp003 = maxBound :: Word32
temp004 = maxBound :: Word16


        -- H/Direct is the Haskell IDL compiler...

demo01    = testParser interface "interface Hello "

demo02    = testParser scopedName "A :: B :: c"
demo02a   = testParser scopedName "a"

demo03    = testParser octal "010" -- 8


demo04 = either print PP.prettyIO =<< parseFromFile specification "test/hello.idl"
   
demo05 = 
    either print PP.prettyIO =<< parseFromFile specification "test/account.idl"

demo06 = 
    either print PP.prettyIO =<< parseFromFile specification "test/Point.idl"



idl_point :: Definition
idl_point = TypeDcl (TyStruct "Point" mems)
  where
    mems = [ Member (TyInt UNSIGNED_LONG_INT) [ SimpleDeclarator "x" ]
           , Member (TyInt UNSIGNED_LONG_INT) [ SimpleDeclarator "x" ]
           ]

demo07 = putStrLn $ render $ PP.definition $ idl_point

demo08 = 
    either print PP.prettyIO =<< HAPPY.parse "test/Point.idl"


-- see C2Hs docs...
demo09 = underscoreToCase "GTK_WINDOW_TOPLEVEL"

demo10 = utc "GTK_WINDOW_TOPLEVEL"


temp01 = rewrite (anyChar >> trailBy toLower) "GTK_WINDOW_TOPLEVEL"
